package com.iplant.wms.service;

import com.iplant.base.po.Pagination;
import com.iplant.base.po.ServiceResult;
import com.iplant.base.po.excel.ExcelData;
import com.iplant.basic.service.po.bms.BMSEmployee;
import com.iplant.basic.service.po.mss.MSSMaterial;
import com.iplant.wms.service.po.asn.*;
import com.iplant.wms.service.po.asn.imp.WMSArrivalNoticeItemImpo;
import com.iplant.wms.service.po.brm.BRMShelvesProp;
import com.iplant.wms.service.po.mfs.WMSStoreStation;
import com.iplant.wms.service.po.mss.MSSMaterialStation;
import com.iplant.wms.service.po.pkg.MSSPackageProp;
import com.iplant.wms.service.po.wms.WMSStock;
import com.iplant.wms.service.po.wpo.WMSPurchaseOrder;

import java.util.Calendar;
import java.util.List;

public interface ASNService {

    ServiceResult<Integer> WMS_UpdateArrivalNotice(BMSEmployee wLoginUser,
                                                   WMSArrivalNotice wWMSArrivalNotice);

    ServiceResult<Integer> WMS_DeleteArrivalNoticeList(BMSEmployee wLoginUser,
                                                       List<WMSArrivalNotice> wArrivalNoticeList);

    ServiceResult<Integer> WMS_UpdateArrivalNoticeItemList(BMSEmployee wLoginUser,
                                                           List<WMSArrivalNoticeItem> wWMSArrivalNoticeItemList);

    ServiceResult<Integer> WMS_UpdateArrivalNoticeItem(BMSEmployee wLoginUser, WMSArrivalNoticeItem wItem);

    ServiceResult<Integer> WMS_DeleteArrivalNoticeItemList(BMSEmployee wLoginUser,
                                                           List<WMSArrivalNoticeItem> wArrivalNoticeItemList);

    ServiceResult<Integer> WMS_DeleteArrivalNotice(
            BMSEmployee wLoginUser, WMSArrivalNotice wArrivalNotice);

    ServiceResult<Integer> WMS_ImportArrivalNotice(BMSEmployee wLoginUser, ExcelData wExcelData);

    ServiceResult<WMSArrivalNotice> WMS_CreateArrivalNotice(BMSEmployee wLoginUser, WMSPurchaseOrder wWMSPurchaseOrder);

    ServiceResult<WMSArrivalNotice> WMS_QueryArrivalNotice(BMSEmployee wLoginUser, int wID, String wCode);


    ServiceResult<Integer> WMS_DeleteArrivalNoticeItem(
            BMSEmployee wLoginUser, WMSArrivalNoticeItem wWMSArrivalNoticeItem);

    ServiceResult<WMSArrivalNoticeItem> WMS_QueryArrivalNoticeItem(BMSEmployee wLoginUser, int wID,
                                                                   String wCode);

    ServiceResult<Integer> WMS_UpdateArrivalVehicleList(BMSEmployee wLoginUser,
                                                        List<WMSArrivalVehicle> wWMSArrivalVehicleList);

    ServiceResult<Integer> WMS_DeleteArrivalVehicleList(BMSEmployee wLoginUser,
                                                        List<WMSArrivalVehicle> wArrivalVehicleList);


    //region 收货单主单据

    /**
     * 由到货单及其子项，创建收货单及其子项
     *
     * @param wLoginUser
     * @param wWMSArrivalNotice
     * @return
     */
    ServiceResult<WMSReceiveBill> WMS_CreateReceiveBill(BMSEmployee wLoginUser, WMSArrivalNotice wWMSArrivalNotice);

    /**
     * 添加或修改收货单
     *
     * @param wLoginUser
     * @param wItem
     * @return
     */
    ServiceResult<Integer> WMS_UpdateReceiveBill(BMSEmployee wLoginUser, WMSReceiveBill wItem);

    /**
     * 删除单条收货单及其子项
     *
     * @param wLoginUser
     * @param wItem
     * @return
     */
    ServiceResult<Integer> WMS_DeleteReceiveBill(BMSEmployee wLoginUser, WMSReceiveBill wItem);

    /**
     * 批量删除收货单及其子项（传对象集合）
     *
     * @param wLoginUser
     * @param wItemList
     * @return
     */
    ServiceResult<Integer> WMS_DeleteReceiveBillList(BMSEmployee wLoginUser, List<WMSReceiveBill> wItemList);


    /**
     * 根据ID或Code查询单条收货单
     *
     * @param wLoginUser
     * @param wID
     * @param wCode
     * @return
     */
    ServiceResult<WMSReceiveBill> WMS_QueryReceiveBillByIDOrCode(BMSEmployee wLoginUser, Integer wID, String wCode);


    ServiceResult<Integer> WMS_DeleteReceiveBillListByIDList(BMSEmployee wLoginUser, List<Integer> wIDList);

    /**
     * 查询指定时间段内的收货单关联的U8单据ID列表，用于判断需要同步的U8单据
     *
     * @param wStartTime
     * @param wEndTime
     * @return
     */
    ServiceResult<List<Integer>> WMS_QueryReceiveBill_U8BillIDList(Calendar wStartTime, Calendar wEndTime);
    //endregion

    //region 收货单子项

    /**
     * 批量保存收货单子项
     *
     * @param wLoginUser
     * @param wItemList
     * @return
     */
    ServiceResult<Integer> WMS_UpdateReceiveBillItemList(BMSEmployee wLoginUser, List<WMSReceiveBillItem> wItemList);

    /**
     * 添加或修改收货单子项
     *
     * @param wLoginUser
     * @param wItem
     * @return
     */
    ServiceResult<Integer> WMS_UpdateReceiveBillItem(BMSEmployee wLoginUser, WMSReceiveBillItem wItem);

    /**
     * 删除单条收货单子项
     *
     * @param wLoginUser
     * @param wItem
     * @return
     */
    ServiceResult<Integer> WMS_DeleteReceiveBillItem(BMSEmployee wLoginUser, WMSReceiveBillItem wItem);

    /**
     * 批量删除收货单子项（传对象集合）
     *
     * @param wLoginUser
     * @param wItemList
     * @return
     */
    ServiceResult<Integer> WMS_DeleteReceiveBillItemList(BMSEmployee wLoginUser, List<WMSReceiveBillItem> wItemList);

    /**
     * 批量删除收货单子项（传IDs）
     *
     * @param wLoginUser
     * @param wIDList
     * @return
     */
    ServiceResult<Integer> WMS_DeleteReceiveBillItemListByIDList(BMSEmployee wLoginUser, List<Integer> wIDList);


    /**
     * 用收货单主单据ID查子项集合
     *
     * @param wLoginUser
     * @param wReceiveBillID
     * @return
     */
    ServiceResult<List<WMSReceiveBillItem>> WMS_QueryReceiveBillItemListByReceiveBillID(BMSEmployee wLoginUser,
                                                                                        int wReceiveBillID,
                                                                                        Pagination wPagination);


    //endregion
    ServiceResult<List<WMSStoreStation>> WMS_CalcReceiveItemStation(BMSEmployee wLoginUser,
                                                                    WMSReceiveBillItem wWMSReceiveItem,
                                                                    MSSPackageProp wMSSPackageProp);


    ServiceResult<List<Integer>> WMS_CalcReceiveItemStation(
            BMSEmployee wLoginUser, WMSReceiveBillItem wWMSReceiveItem, List<MSSMaterialStation> wMaterialStationList,
            BRMShelvesProp wBRMShelvesProp, MSSPackageProp wMSSPackageProp, MSSMaterial wMSSMaterial,
            List<MSSMaterial> wMSSMaterialList,
            double wMaterialNumber, double wTotalVolume, double wTotalGrossWeight, List<WMSStock> wStockList,
            List<WMSStoreStation> wStoreStationList);

    ServiceResult<Integer> WMS_UpdateInspectTask(BMSEmployee wLoginUser,
                                                 WMSInspectTask wInspectTask);

    ServiceResult<Integer> WMS_DeleteInspectTaskList(BMSEmployee wLoginUser,
                                                     List<WMSInspectTask> wInspectTaskList);


    ServiceResult<List<WMSInspectTask>> WMS_QueryInspectTaskList(
            BMSEmployee wLoginUser, String wPurchaseOrderCode, String wPurchaseOrderItemCode, String wArrivalNoticeCode,
            String wArrivalNoticeItemCode, int wTypeID, int wNoticeStatus, int wNoticeItemStatus, int wInspectorID,
            int wInspectResult, int wStoreID, String wStoreCode, int wCustomerID, String wCustomerCode, int wSupplierID,
            String wSupplierCode, String wMaterialNo, String wMaterialName, int wCreatorID, int wActive,
            Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<WMSInspectTask> WMS_QueryInspectTask(BMSEmployee wLoginUser, int wID, String wCode);

    ServiceResult<Integer> WMS_UpdateInspectTaskItemList(BMSEmployee wLoginUser,
                                                         List<WMSInspectTaskItem> wWMSInspectTaskItemList);

    ServiceResult<Integer> WMS_DeleteInspectTaskItemList(BMSEmployee wLoginUser,
                                                         List<WMSInspectTaskItem> wInspectTaskItemList);

    ServiceResult<List<WMSInspectTaskItem>> WMS_QueryInspectTaskItemList(
            BMSEmployee wLoginUser, String wPurchaseOrderCode, String wPurchaseOrderItemCode,
            String wArrivalNoticeCode, String wArrivalNoticeItemCode,
            int wTypeID, int wIPTStatus, int wInspectorID, int wInspectResult, int wStoreID,
            String wStoreCode,
            String wMaterialNo, String wMaterialName, int wActive,
            Calendar wStartTime, Calendar wEndTime, Pagination wPagination);

    ServiceResult<WMSInspectTaskItem> WMS_QueryInspectTaskItem(BMSEmployee wLoginUser, int wID,
                                                               String wCode);

    ServiceResult<WMSInspectTask> WMS_CreateInspectTask(
            BMSEmployee wLoginUser, WMSArrivalNoticeItem wWMSArrivalNoticeItem);

    ServiceResult<List<WMSArrivalNoticeItemImpo>> ASN_ImportArrivalNoticeItems(BMSEmployee wLoginUser, ExcelData wExcelData);
}
